home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fs / fs.h < prev    next >
C/C++ Source or Header  |  1991-04-12  |  25KB  |  592 lines

  1. /*
  2.  * fs.h --
  3.  *
  4.  *    The external interface to the filesystem module is defined here.
  5.  *    The main object at the interface level is Fs_Stream.  A standard set
  6.  *    of operations apply to all streams.  A stream is created by
  7.  *    Fs_Open on a pathname, with flags used to differentiate between
  8.  *    the different kinds of streams.  After that, the main operations
  9.  *    are Fs_Read, Fs_Write, Fs_IOControl, Fs_Select, and Fs_Close.
  10.  *
  11.  *    Parts of the Fs to Dev interface are also described here, including
  12.  *    Fs_Device, which describes a device, and Fs_IOParam, Fs_IOCParam,
  13.  *    and Fs_IOReply, which are standard parameter blocks.
  14.  *
  15.  * Copyright (C) 1987 Regents of the University of California
  16.  * All rights reserved.
  17.  * Permission to use, copy, modify, and distribute this
  18.  * software and its documentation for any purpose and without
  19.  * fee is hereby granted, provided that the above copyright
  20.  * notice appear in all copies.  The University of California
  21.  * makes no representations about the suitability of this
  22.  * software for any purpose.  It is provided "as is" without
  23.  * express or implied warranty.
  24.  *
  25.  *
  26.  * $Header: /sprite/src/kernel/fs/RCS/fs.h,v 9.14 91/04/12 17:34:05 kupfer Exp $ SPRITE (Berkeley)
  27.  */
  28.  
  29. #ifndef _FS
  30. #define _FS
  31.  
  32. #ifdef KERNEL
  33. #include <sys.h>
  34. #include <syncTypes.h>
  35. #include <procTypes.h>
  36. #include <user/fs.h>
  37. #include <fmt.h>
  38. #include <bstring.h>
  39. #else
  40. #include <kernel/sys.h>
  41. #include <kernel/syncTypes.h>
  42. #include <kernel/procTypes.h>
  43. #include <fs.h>
  44. #include <fmt.h>
  45. #endif
  46.  
  47. /*
  48.  * Fragment stuff that is dependent on the filesystem block size
  49.  * defined in user/fs.h.  Actually, the fragmenting code is specific
  50.  * to a 4K block size and a 1K fragment size.
  51.  */
  52.  
  53. #define    FS_BLOCK_OFFSET_MASK    (FS_BLOCK_SIZE - 1)
  54. #define    FS_FRAGMENT_SIZE    1024
  55. #define    FS_FRAGMENTS_PER_BLOCK    4
  56.  
  57.  
  58. /*
  59.  * The following structure is referenced by the process table entry for
  60.  * a process.  It contains all the filesystem related state for the process.
  61.  */
  62. typedef struct Fs_ProcessState {
  63.     struct Fs_Stream    *cwdPtr;    /* The current working directory. */
  64.     unsigned int       filePermissions;/* The bits in this mask correspond
  65.                      * to the permissions mask of a file.
  66.                      * If one of these bits is set it
  67.                      * TURNS OFF the corresponding
  68.                      * permission when a file is created. */
  69.     int               numStreams;    /* Size of streamList array. */
  70.     struct Fs_Stream   **streamList;    /* Array of pointers to open files.
  71.                      * This list is indexed by an integer
  72.                      * known as a streamID. */
  73.     char        *streamFlags;    /* Array of flags, one for element
  74.                      * for each open stream.  Used to
  75.                      * keep the close-on-exec property */
  76.     int            numGroupIDs;    /* The length of the groupIDs array */
  77.     int            *groupIDs;    /* An array of group IDs.  Group IDs
  78.                      * are used similarly to the User ID. */
  79. } Fs_ProcessState;
  80.  
  81.  
  82. /*
  83.  * The following low-level file system types have to be exported because
  84.  * the type of Fs_Stream is already exported.  This could be fixed by
  85.  * only exporting an opaque Fs_StreamPtr type, or by changing the definition
  86.  * of Fs_Stream from a struct to a pointer to the struct.
  87.  */
  88.  
  89. /*
  90.  * All kinds of things are referenced from the object hash table.  The generic
  91.  * term for each structure is "handle".  The following structure defines a 
  92.  * common structure needed in the beginning of each handle.  Note, most of
  93.  * these fields are private to the FsHandle* routines that do generic
  94.  * operations on handles.  One exception is that the refCount on FSIO_STREAM
  95.  * handles is manipulated by the stream routines.  The handle must be
  96.  * locked when examining the refCount, and it should only be changed
  97.  * under the handle monitor lock by the FsHandle* routines.
  98.  */
  99.  
  100. typedef struct Fs_HandleHeader {
  101.     Fs_FileID        fileID;        /* Used as the hash key. */
  102.     int            flags;        /* Defined in fsHandle.c. */
  103.     Sync_Condition    unlocked;    /* Notified when handle is unlocked. */
  104.     int            refCount;    /* Used for garbage collection. */
  105.     char        *name;        /* Used for error messages */
  106.     List_Links        lruLinks;    /* For LRU list of handles */
  107. #ifndef CLEAN
  108.     Proc_ControlBlock    *lockProcPtr;    /* pcb of process that has the 
  109.                      * lock */
  110. #endif
  111. } Fs_HandleHeader;
  112.  
  113. #define LRU_LINKS_TO_HANDLE(listPtr) \
  114.     ( (Fs_HandleHeader *)((int)(listPtr) - sizeof(Fs_FileID) \
  115.         - 2 * sizeof(int) - sizeof(char *) - sizeof(Sync_Condition)) )
  116.  
  117.  
  118.  
  119. /*
  120.  * The following name-related information is referenced by each stream.
  121.  * This identifies the name of the file, which will be different than
  122.  * the file itself in the case of devices.  This is used to get to the
  123.  * name server during set/get attributes operations.  Also, this name
  124.  * fileID is used as the starting point for relative lookups.
  125.  */
  126.  
  127. typedef struct Fs_NameInfo {
  128.     Fs_FileID        fileID;        /* Identifies file and name server. */
  129.     Fs_FileID        rootID;        /* ID of file system root.  Passed
  130.                      * to name server to prevent ascending
  131.                      * past the root of a domain with ".."*/
  132.     int            domainType;    /* Name domain type */
  133.     struct Fsprefix    *prefixPtr;    /* Back pointer to prefix table entry.
  134.                      * This is kept for efficient handling
  135.                      * of lookup redirects. */
  136. } Fs_NameInfo;
  137.  
  138. /*
  139.  * Fs_Stream - A clients handle on an open file is defined by the Fs_Stream
  140.  *      structure.  A stream has a read-write offset index, state flags
  141.  *    that determine how the stream is being used (ie, for reading
  142.  *    or writing, etc.), name state used for get/set attributes,
  143.  *    and an I/O handle used for I/O operations.
  144.  *    There are many different types of I/O handles; they correspond
  145.  *    to local files, remote files, local devices, remote devices,
  146.  *    local pipes, remote pipes, locally cached named pipes,
  147.  *    remotely cached named pipes, control streams for pseudo devices,
  148.  *    psuedo streams, their corresponding server streams, etc. etc.
  149.  *    The different I/O handles types are defined in fsInt.h
  150.  *
  151.  *    This top level Fs_Stream structure is also given a handle type
  152.  *    and kept in the handle table because of process migration and
  153.  *    the shadow streams that file servers have to keep - on both
  154.  *    the client and the server there will be a Fs_Stream that
  155.  *    references an I/O handle.  The I/O handles will be different
  156.  *    types on the client (i.e. remote file) and the server (local file).
  157.  *    The Fs_Stream object will be the same, however, with the same
  158.  *    usage flags and internal ID.
  159.  *
  160.  */
  161.  
  162. typedef struct Fs_Stream {
  163.     Fs_HandleHeader    hdr;        /* Global stream identifier.  This
  164.                      * includes a reference count which
  165.                      * is incremented on fork/dup */
  166.     int            offset;        /* File access position */
  167.     int            flags;        /* Flags defined below */
  168.     Fs_HandleHeader    *ioHandlePtr;    /* Stream specific data used for I/O.
  169.                      * This really references a somewhat
  170.                      * larger object, see fsInt.h */
  171.     Fs_NameInfo         *nameInfoPtr;    /* Used to contact the name server */
  172.     List_Links        clientList;    /* Needed for recovery and sharing
  173.                      * detection */
  174. } Fs_Stream;
  175.  
  176. /*
  177.  * Flags in Fs_Stream that are only set/used by the kernel.
  178.  * (Flags passed in from callers of Fs_Open are defined in user/fs.h
  179.  *  The low order 12 bits of the flags word are reserved for those flags.)
  180.  * There are two groups of flags, the first is used mainly at lookup time
  181.  *    and the rest apply to I/O operations.
  182.  *
  183.  *    (These open related bit values are defined in user/fs.h)
  184.  *    FS_CREATE - Create if it doesn't exist.
  185.  *    FS_TRUNC  - Truncate to zero length on opening
  186.  *    FS_EXCULSIVE - With FS_CREATE causes open to fail if the file exists.
  187.  *    FS_MASTER - Open pseudo-device as the server process
  188.  *    FS_NAMED_PIPE_OPEN - Open a named pipe
  189.  *    FS_CLOSE_ON_EXEC - Cause stream to be closed when the opening
  190.  *        process executes a different program.
  191.  *
  192.  *    (These I/O related bit values are defined in user/fs.h)
  193.  *    FS_READ - Open for reading    (also FS_READABLE)
  194.  *    FS_WRITE - Open for writing    (also FS_WRITABLE)
  195.  *    FS_EXECUTE - Open for execution    (also FS_EXCEPTION)
  196.  *    FS_APPEND - Open for append mode
  197.  *    FS_NON_BLOCKING - Open a stream with non-blocking I/O operations. If
  198.  *        the operation would normally block, FS_WOULD_BLOCK is returned.
  199.  *
  200.  *    (These open-time bit values are defined below)
  201.  *      FS_FOLLOW - follow symbolic links during look up.
  202.  *    FS_PREFIX - Set when opening prefixes for export.
  203.  *    FS_SWAP - Set when opening swap files.  They are not cached on
  204.  *        remote clients and this flag is used to set caching state.
  205.  *    FS_OWNERSHIP - ownership permission.  The calling process has to
  206.  *        own the file in order for a lookup to succeed.  This is
  207.  *        used for setting attributes.
  208.  *    FS_DELETE - Open a file for deletion.  Write permission is needed
  209.  *        in the parent directory for this to succeed.
  210.  *    FS_LINK - This is used by FslclLookup to make hard links.  Instead
  211.  *        of creating a new file, FslclLookup makes another directory
  212.  *        reference (hard link) to an existing file.
  213.  *    FS_RENAME - This goes with FS_LINK if the link is being made in
  214.  *        preparation for a rename operation.  This allows the link,
  215.  *        which in this case is temporary, to be made to a directory.
  216.  *
  217.  *    (These I/O related bit values are defined below)
  218.  *      FS_USER - the file is a user file.  The buffer space is
  219.  *              in a user's address space.
  220.  *    FS_USER_IN - For I/O Control, the input buffer is in user space
  221.  *    FS_USER_OUT - For I/O Control, the output buffer is in user space
  222.  *    FS_CLIENT_CACHE_WRITE -    This write is coming from a client's cache.
  223.  *              This means the modify time should not be updated
  224.  *              since the client has the correct modify time.
  225. #ifdef SOSP91
  226.  *    FS_DIR - This is a directory.
  227. #endif SOSP91
  228.  *    FSUTIL_TRACE_FLAG - This is used to enable the taking of trace records
  229.  *        by low level routines.  This means that the tracing can
  230.  *        be confined to particular operations, like open, while
  231.  *        other operations, like remove, don't pollute the trace.
  232.  *    FS_SERVER_WRITE_THRU - Set on writes that are supposed to be written
  233.  *                   through to the server.
  234.  *    FS_HEAP - This is a heap page for special treatment in the cache.
  235.  *    FS_RMT_SHARED - Set on streams that are shared among clients on
  236.  *        separate machines.  For regular files this means that the
  237.  *        stream offset is being maintained on the server.
  238.  *    FS_NEW_STREAM - Migration related.  This tells the I/O server that
  239.  *        the destination of a migration is getting a stream for
  240.  *        the first time.   It needs to know this in order to do
  241.  *        I/O client book-keeping correctly.
  242.  *    FS_WRITE_TO_DISK - Write this block through to disk.
  243.  *    FS_MAP - File is being mapped into virtual memory.
  244.  *    FS_MIGRATED_FILE - Migration related.  This says a file has been
  245.  *        involved in a migration, so (for example) if the file
  246.  *        gets flushed to the server then the host that's flushing
  247.  *        it knows to attribute the flush to migration.  Used
  248.  *        for statistics.
  249.  *    FS_MIGRATING - Migration related.  This says a file is in the
  250.  *        process of migrating.  Also used for statistics.
  251.  *        MIGRATED_FILE stays set for any file that has ever been
  252.  *        migrated (it is reset if the file is not open anywhere), while
  253.  *        MIGRATING is set as a temporary flag during cache consistency
  254.  *        operations, for a single reference to the file.
  255.  */
  256. #define FS_KERNEL_FLAGS        0xfffff000
  257. #define FS_FOLLOW        0x00001000
  258. #define FS_PREFIX        0x00002000
  259. #define FS_SWAP            0x00004000
  260. #define FS_USER            0x00008000
  261. #define FS_USER_IN        FS_USER
  262. #define FS_OWNERSHIP        0x00010000
  263. #define FS_DELETE        0x00020000
  264. #define FS_LINK            0x00040000
  265. #define FS_RENAME        0x00080000
  266. #define FS_CLIENT_CACHE_WRITE    0x00100000
  267. #ifdef SOSP91
  268. #define FS_DIR            0x00200000
  269. #endif SOSP91
  270. #define FSUTIL_TRACE_FLAG    0x00400000
  271. #define FS_USER_OUT        0x00800000
  272. #define    FS_SERVER_WRITE_THRU    0x01000000
  273. #define    FS_HEAP            0x02000000
  274. #define FS_RMT_SHARED        0x04000000
  275. #define FS_NEW_STREAM        0x08000000
  276. #define    FS_WRITE_TO_DISK    0x10000000
  277. #define    FS_MAP            0x20000000
  278. #define    FS_MIGRATED_FILE    0x40000000
  279. #define    FS_MIGRATING        0x80000000
  280.  
  281.  
  282. /*
  283.  * Basic I/O parameters.  Note that the stream is identified by context,
  284.  * either the pseudo-device connection or additional RPC parameters.
  285.  * This structure is initialized in Fs_Read/Write and passed down to
  286.  * the stream-specific I/O routines.  This record should be considered
  287.  * read-only to avoid conflicts with other layers.
  288.  * Fs_IOReply is used to return information about the transfer.
  289.  */
  290.  
  291. typedef struct Fs_IOParam {
  292.     Address    buffer;            /* Buffer for data */
  293.     int        length;            /* Byte amount to transfer */
  294.     int        offset;            /* Byte offset at which to transfer */
  295.     int        flags;            /* Operation specific flags */
  296.     Proc_PID    procID;            /* Process ID and Family ID of this */
  297.     Proc_PID    familyID;        /* process */
  298.     int        uid;            /* Effective user ID */
  299.     int        reserved;        /* Not used */
  300. } Fs_IOParam;
  301.  
  302. /*
  303.  * FsSetIOParam - macro to initialize Fs_IOParam record.
  304.  */
  305. #define FsSetIOParam(ioPtr, zbuffer, zlength, zoffset, zflags) \
  306.     { \
  307.     register Proc_ControlBlock *procPtr = Proc_GetEffectiveProc(); \
  308.     (ioPtr)->buffer = zbuffer; \
  309.     (ioPtr)->length = zlength; \
  310.     (ioPtr)->offset = zoffset; \
  311.     (ioPtr)->flags = zflags; \
  312.     (ioPtr)->procID = procPtr->processID; \
  313.     (ioPtr)->familyID = procPtr->familyID; \
  314.     (ioPtr)->uid = procPtr->userID; \
  315.     (ioPtr)->reserved = 0; \
  316.     }
  317.  
  318. /*
  319.  * Fs_IOReply is used to return info from stream-specific I/O routines
  320.  * back up to Fs_Read/Write.  The length has to be updated to reflect how
  321.  * much data was transferred.  The routines can also cause a signal to
  322.  * be generated by setting signal to non-zero.  The signal and code
  323.  * are initialized to zero by top-level routines, so these fields can
  324.  * be ignored if no signal is to be generated.  Finally, the flags field
  325.  * contains the three select bits that indicate the state of the object
  326.  * after the operation.
  327.  */
  328. typedef struct Fs_IOReply {
  329.     int        length;            /* Amount transferred */
  330.     int        flags;            /* Stream flags used, noted below. */
  331.     int        signal;            /* Signal to generate, or zero */
  332.     int        code;            /* Code to modify signal */
  333. } Fs_IOReply;
  334.  
  335. /*
  336.  * Flag bits for Fs_IOReply:
  337.  *    FS_READABLE        Object is currently readable
  338.  *    FS_WRITABLE        Object is currently writable
  339.  *    FS_EXCEPTION        Object has an outstanding exception
  340.  *
  341.  * These bits are defined above because they come from the stream flags.
  342.  */
  343.  
  344. /*
  345.  * Parameters for I/O Control.  There is also a returned Fs_IOReply
  346.  * that specifies the amount of valid data in the outBuffer,
  347.  * and a signal to return, if any.
  348.  */
  349.  
  350. typedef struct Fs_IOCParam {
  351.     int        command;    /* I/O Control to perform. */
  352.     Address    inBuffer;    /* Input buffer */
  353.     int        inBufSize;    /* Size of input params to iocontrol. */
  354.     Address    outBuffer;    /* Output buffer */
  355.     int        outBufSize;    /* Size of results from iocontrol. */
  356.     Fmt_Format    format;        /* Defines client's byte order/alignment
  357.                  * format. */
  358.     Proc_PID    procID;        /* ID of invoking process */
  359.     Proc_PID    familyID;    /* Family of invoking process */
  360.     int        uid;        /* Effective user ID */
  361.     int        flags;        /* FS_USER_IN and FS_USER_OUT indicate if
  362.                  * input and output buffers are in user space,
  363.                  * respectively */
  364. } Fs_IOCParam;
  365.  
  366. /*
  367.  * FS_MAX_LINKS    - the limit on the number of symbolic links that can be
  368.  *    expanded within a single domain.  This is also the limit on the
  369.  *    number of re-directs between domains that can occur during lookup.
  370.  */
  371. #define FS_MAX_LINKS    10
  372.  
  373. /*
  374.  * Values for  page type for Fs_PageRead.
  375.  */
  376. typedef enum {
  377.     FS_CODE_PAGE,
  378.     FS_HEAP_PAGE,
  379.     FS_SWAP_PAGE,
  380.     FS_SHARED_PAGE
  381. } Fs_PageType;
  382.  
  383.  
  384. /*
  385.  * Device drivers use Fs_NotifyReader and Fs_NotifyWriter to indicate
  386.  * that a device is ready.  They pass a Fs_NotifyToken as an argument
  387.  * that represents to the file system the object that is ready.
  388.  */
  389. typedef Address Fs_NotifyToken;
  390.  
  391. /*
  392.  * Flags returned from device driver open procedures.
  393.  *
  394.  * FS_DEV_DONT_LOCK    - Do not lock the device's handle during IO operations.
  395.  *              The default is to only allow one call to a device's
  396.  *              read or write procedures active at any time. Device's
  397.  *              that set this flag are responsible for doing their
  398.  *              own synchronization.
  399.  * FS_DEV_DONT_COPY    - Do not copy user resident IO buffers in and out of
  400.  *              the kernel for this device. The default is to 
  401.  *              malloc() a kernel resident buffer for device IO
  402.  *              operation.  Device's that set this flag are
  403.  *              responsible for doing IO operations directly to
  404.  *              user's address spaces.
  405.  */
  406.  
  407. #define    FS_DEV_DONT_LOCK    0x1
  408. #define    FS_DEV_DONT_COPY    0x2
  409.  
  410. /*
  411.  * TRUE once the file system has been initialized, so we
  412.  * know we can sync the disks safely.
  413.  */
  414. extern  Boolean fsutil_Initialized;    
  415.  
  416. /*
  417.  * These record the maximum transfer size supported by the RPC system.
  418.  */
  419. extern int fsMaxRpcDataSize;
  420. extern int fsMaxRpcParamSize;
  421.  
  422. /*
  423.  * Filesystem initialization calls.
  424.  */
  425. extern void Fs_Init _ARGS_((void));
  426. extern void Fs_InitData _ARGS_((void));
  427. extern void Fs_InitNameSpace _ARGS_((void));
  428. extern void Fs_Bin _ARGS_((void));
  429. extern void Fs_ProcInit _ARGS_((void));
  430. extern void Fs_InheritState _ARGS_((Proc_ControlBlock *parentProcPtr,
  431.                 Proc_ControlBlock *newProcPtr));
  432. extern void Fs_CloseState _ARGS_((Proc_ControlBlock *procPtr, int phase));
  433.  
  434.  
  435. /*
  436.  * Filesystem system calls.
  437.  */
  438. extern ReturnStatus Fs_AttachDiskStub _ARGS_((char *userDeviceName, 
  439.             char *userLocalName, int flags));
  440. extern ReturnStatus Fs_ChangeDirStub _ARGS_((char *pathName));
  441. extern ReturnStatus Fs_RemoveStub _ARGS_((char *pathName));
  442. extern ReturnStatus Fs_CommandStub _ARGS_((int command, int bufSize, 
  443.             Address buffer));
  444. extern ReturnStatus Fs_CreatePipeStub _ARGS_((int *inStreamIDPtr, 
  445.             int *outStreamIDPtr));
  446. extern ReturnStatus Fs_GetAttributesIDStub _ARGS_((int streamID, 
  447.             Fs_Attributes *attrPtr));
  448. extern ReturnStatus Fs_GetAttributesStub _ARGS_((char *pathName, 
  449.             int fileOrLink, Fs_Attributes *attrPtr));
  450. extern ReturnStatus Fs_GetNewIDStub _ARGS_((int streamID, int *newStreamIDPtr));
  451. extern ReturnStatus Fs_HardLinkStub _ARGS_((char *fileName, char *linkName));
  452. extern ReturnStatus Fs_IOControlStub _ARGS_((int streamID, int command, 
  453.             int inBufSize, Address inBuffer, int outBufSize, 
  454.             Address outBuffer));
  455. extern ReturnStatus Fs_MakeDeviceStub _ARGS_((char *pathName, 
  456.             Fs_Device *devicePtr, int permissions));
  457. extern ReturnStatus Fs_MakeDirStub _ARGS_((char *pathName, int permissions));
  458. extern ReturnStatus Fs_OpenStub _ARGS_((char *pathName, int usageFlags, 
  459.             int permissions, int *streamIDPtr));
  460. extern ReturnStatus Fs_ReadLinkStub _ARGS_((char *linkName, int bufSize, 
  461.             char *buffer, int *linkSizePtr));
  462. extern ReturnStatus Fs_ReadStub _ARGS_((int streamID, int amountRead, 
  463.             Address buffer, int *amountReadPtr));
  464. extern ReturnStatus Fs_ReadVectorStub _ARGS_((int streamID, int numVectors, 
  465.             Fs_IOVector userVectorArray[], int *amountReadPtr));
  466. extern ReturnStatus Fs_RemoveDirStub _ARGS_((char *pathName));
  467. extern ReturnStatus Fs_RemoveDirStub _ARGS_((char *pathName));
  468. extern ReturnStatus Fs_RenameStub _ARGS_((char *pathName, char *newName));
  469. extern ReturnStatus Fs_SelectStub _ARGS_((int numStreams, Time *userTimeoutPtr,
  470.             int *userReadMaskPtr, int *userWriteMaskPtr, 
  471.             int *userExceptMaskPtr, int *numReadyPtr));
  472. extern ReturnStatus Fs_SetAttributesIDStub _ARGS_((int streamID, 
  473.             Fs_Attributes *attrPtr));
  474. extern ReturnStatus Fs_SetAttributesStub _ARGS_((char *pathName, 
  475.             int fileOrLink, Fs_Attributes *attrPtr));
  476. extern ReturnStatus Fs_SetAttrIDStub _ARGS_((int streamID, 
  477.             Fs_Attributes *attrPtr, int flags));
  478. extern ReturnStatus Fs_SetAttrStub _ARGS_((char *pathName, int fileOrLink, 
  479.             Fs_Attributes *attrPtr, int flags));
  480. extern ReturnStatus Fs_SetDefPermStub _ARGS_((int permissions, int *oldPermPtr));
  481. extern ReturnStatus Fs_SymLinkStub _ARGS_((char *targetName, 
  482.             char *linkName, Boolean remoteFlag));
  483. extern ReturnStatus Fs_WriteStub _ARGS_((int streamID, int writeLength, 
  484.             Address buffer, int *writeLengthPtr));
  485. extern ReturnStatus Fs_WriteVectorStub _ARGS_((int streamID, int numVectors,
  486.             Fs_IOVector userVectorArray[], int *amountWrittenPtr));
  487. extern ReturnStatus Fs_FileWriteBackStub _ARGS_((int streamID, int firstByte, 
  488.             int lastByte, Boolean shouldBlock));
  489.  
  490. /*
  491.  * Filesystem system calls given accessible arguments.
  492.  */
  493. extern ReturnStatus Fs_UserClose _ARGS_((int streamID));
  494. extern ReturnStatus Fs_UserRead _ARGS_((int streamID, int amountRead,
  495.             Address buffer, int *amountReadPtr));
  496. extern ReturnStatus Fs_UserReadVector _ARGS_((int streamID, int numVectors, 
  497.             Fs_IOVector *vectorPtr, int *amountReadPtr));
  498. extern ReturnStatus Fs_UserWrite _ARGS_((int streamID, int writeLength, 
  499.             Address buffer, int *writeLengthPtr));
  500. extern ReturnStatus Fs_WriteVectorStub _ARGS_((int streamID, int numVectors, 
  501.             Fs_IOVector userVectorArray[], int *amountWrittenPtr));
  502. extern ReturnStatus Fs_UserWriteVector _ARGS_((int streamID, int numVectors, 
  503.             Fs_IOVector *vectorPtr, int *amountWrittenPtr));
  504.  
  505. /*
  506.  * Kernel equivalents of the filesystem system calls.
  507.  */
  508. extern ReturnStatus Fs_ChangeDir _ARGS_((char *pathName));
  509. extern ReturnStatus Fs_Close _ARGS_((register Fs_Stream *streamPtr));
  510. extern ReturnStatus Fs_Command _ARGS_((int command, int bufSize, 
  511.             Address buffer));
  512. extern ReturnStatus Fs_CheckAccess _ARGS_((char *pathName, int perm, 
  513.             Boolean useRealID));
  514. extern ReturnStatus Fs_GetAttributes _ARGS_((char *pathName, int fileOrLink,
  515.             Fs_Attributes *attrPtr));
  516. extern ReturnStatus Fs_GetNewID _ARGS_((int streamID, int *newStreamIDPtr));
  517. extern ReturnStatus Fs_HardLink _ARGS_((char *pathName, char *linkName));
  518. extern ReturnStatus Fs_IOControl _ARGS_((Fs_Stream *streamPtr,
  519.             Fs_IOCParam *ioctlPtr, Fs_IOReply *replyPtr));
  520. extern ReturnStatus Fs_MakeDevice _ARGS_((char *name, Fs_Device *devicePtr,
  521.             int permissions));
  522. extern ReturnStatus Fs_MakeDir _ARGS_((char *name, int permissions));
  523. extern ReturnStatus Fs_Open _ARGS_((char *name, register int useFlags, 
  524.             int type, int permissions, Fs_Stream **streamPtrPtr));
  525. extern ReturnStatus Fs_Read _ARGS_((Fs_Stream *streamPtr, Address buffer, 
  526.             int offset, int *lenPtr));
  527. extern ReturnStatus Fs_Remove _ARGS_((char *name));
  528. extern ReturnStatus Fs_RemoveDir _ARGS_((char *name));
  529. extern ReturnStatus Fs_Rename _ARGS_((char *pathName, char *newName));
  530. extern ReturnStatus Fs_SetAttributes _ARGS_((char *pathName, int fileOrLink, 
  531.             Fs_Attributes *attrPtr, int flags));
  532. extern ReturnStatus Fs_SymLink _ARGS_((char *targetName, char *linkName, 
  533.             Boolean remoteFlag));
  534. extern ReturnStatus Fs_Trunc _ARGS_((char *pathName, int length));
  535. extern ReturnStatus Fs_TruncStream _ARGS_((Fs_Stream *streamPtr, int length));
  536. extern ReturnStatus Fs_Write _ARGS_((Fs_Stream *streamPtr, Address buffer, 
  537.             int offset, int *lenPtr));
  538.  
  539. /*
  540.  * Filesystem utility routines.
  541.  */
  542. extern void Fs_CheckSetID _ARGS_((Fs_Stream *streamPtr, int *uidPtr, 
  543.                 int *gidPtr));
  544. extern void Fs_CloseOnExec _ARGS_((Proc_ControlBlock *procPtr));
  545.  
  546.  
  547. /*
  548.  * Routines to support process migration: encapsulate and deencapsulate
  549.  * streams and other file state, and clear file state after migration.
  550.  */
  551. extern ReturnStatus Fs_InitiateMigration _ARGS_((Proc_ControlBlock *procPtr, 
  552.             int hostID, Proc_EncapInfo *infoPtr));
  553. extern int Fs_GetEncapSize _ARGS_((void));
  554. extern ReturnStatus Fs_EncapFileState _ARGS_((Proc_ControlBlock *procPtr, 
  555.             int hostID, Proc_EncapInfo *infoPtr, 
  556.             Address ptr));
  557. extern ReturnStatus Fs_DeencapFileState _ARGS_((Proc_ControlBlock *procPtr, 
  558.              Proc_EncapInfo *infoPtr, Address buffer));
  559.  
  560. /*
  561.  * Routines for virtual memory.
  562.  */
  563. extern ReturnStatus Fs_PageRead _ARGS_((Fs_Stream *streamPtr, Address pageAddr,
  564.             int offset, int numBytes, Fs_PageType pageType));
  565. extern ReturnStatus Fs_PageWrite _ARGS_((Fs_Stream *streamPtr,Address pageAddr,
  566.             int offset, int numBytes, Boolean toDisk));
  567. extern ReturnStatus Fs_PageCopy _ARGS_((Fs_Stream *srcStreamPtr, 
  568.             Fs_Stream *destStreamPtr, int offset, int numBytes));
  569. extern ReturnStatus Fs_FileBeingMapped _ARGS_((Fs_Stream *streamPtr, 
  570.             int isMapped));
  571.  
  572. /*
  573.  * Routines that map to/from user-level streamIDs.
  574.  */
  575. extern ReturnStatus Fs_GetStreamID _ARGS_((Fs_Stream *streamPtr, 
  576.             int *streamIDPtr));
  577. extern void Fs_ClearStreamID _ARGS_((int streamID, Proc_ControlBlock *procPtr));
  578. extern ReturnStatus Fs_GetStreamPtr _ARGS_((Proc_ControlBlock *procPtr, 
  579.             int streamID, Fs_Stream **streamPtrPtr));
  580.  
  581. extern ReturnStatus Fs_GetAttrStream _ARGS_((Fs_Stream *streamPtr, 
  582.             Fs_Attributes *attrPtr));
  583. extern ReturnStatus Fs_SetAttrStream _ARGS_((Fs_Stream *streamPtr,
  584.             Fs_Attributes *attrPtr, Fs_UserIDs *idPtr, int flags));
  585. extern void Fs_CheckSetID _ARGS_((Fs_Stream *streamPtr, int *uidPtr, 
  586.             int *gidPtr));
  587.  
  588. extern ClientData Fs_GetFileHandle _ARGS_((Fs_Stream *streamPtr));
  589. extern struct Vm_Segment **Fs_GetSegPtr _ARGS_((ClientData fileHandle));
  590.  
  591. #endif /* _FS */
  592.